<template>
  <div>
    <div class="my-body">
      <el-row>
        <el-col :span="24">
          <div class="ipt_a">
            <div style="float: left; line-height: 30px" class="tab_font-size">
              医院地区：
            </div>
            <el-input
              v-model="input"
              placeholder="请输入内容"
              style="width: 150px; height: 50px; float: left"
            ></el-input>
          </div>
          <div class="ipt_a">
            <div style="float: left; line-height: 30px" class="tab_font-size">
              订货状态：
            </div>
            <el-select v-model="value" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </div>

          <div class="ipt_b">
            <div style="float: left; line-height: 30px" class="tab_font-size">
              申请日期
            </div>
            <div style="margin-left: 20px; float: left">
              <el-date-picker
                v-model="value1"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker>
            </div>
          </div>
          <div style="float: left">
            <el-button type="primary" plain>查询</el-button>
            <el-button plain>清空</el-button>
          </div>
        </el-col>
      </el-row>
      <div>
        <el-button type="primary" @click="dinhuoshenq" plain
          >申请</el-button
        >
        <el-button type="danger" plain>删除</el-button>
        <el-dialog
          title="添加订货申请"
          :visible.sync="dialogVisible"
          width="50%"
          :before-close="handleClose"
        >
          <div style="width: 100%">
            <el-form ref="form" :model="form" label-width="80px">
              
              <el-form-item label="经销商">
                <el-input v-model="form.com_id" style="width: 100px"></el-input>
                <el-input v-model="form.name" style="width: 200px"></el-input>
                <!-- <el-button type="primary" @click="onSubmit">...</el-button> -->
              </el-form-item>

              <el-form-item label="医院(地区)">
                <el-input
                  v-model="form.yiyiancode"
                  style="width: 100px"
                ></el-input>
                <el-input
                  v-model="form.yiyianname"
                  style="width: 200px"
                ></el-input>
                <el-button type="primary" @click="dialogVisiblea = true"
                  >...</el-button
                >
              </el-form-item>
              <!-- <el-form-item label="有效授权编号">
                <el-select
                  v-model="form.region"
                  placeholder="请选择有效授权编号"
                >
                  <el-option label="产品近效期" value="shanghai"></el-option>
                  <el-option label="投诉" value="beijing"></el-option>
                  <el-option label="保障" value="beijing"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="合同编号">
                <el-select
                  v-model="form.region"
                  placeholder="请选择合同编号"
                >
                  <el-option label="产品近效期" value="shanghai"></el-option>
                  <el-option label="投诉" value="beijing"></el-option>
                  <el-option label="保障" value="beijing"></el-option>
                </el-select>
              </el-form-item> -->

              <el-form-item label="发票地址">
                <el-input
                  v-model="form.fp_addressname"
                  style="width: 80%"
                ></el-input>
                <el-button type="primary" @click="jinxiaoshangdz(1)"
                  >...</el-button
                >
              </el-form-item>
              <el-form-item label="合同地址">
                <el-input
                  v-model="form.ht_addressname"
                   style="width: 80%"
                ></el-input>
                <el-button type="primary" @click="jinxiaoshangdz(2)"
                  >...</el-button
                >
              </el-form-item>
              <el-form-item label="收货地址">
                <el-input
                  v-model="form.sh_addressname"
                  style="width: 80%"
                ></el-input>
                <el-button type="primary" @click="jinxiaoshangdz(3)"
                  >...</el-button
                >
              </el-form-item>

              <el-form-item>
                <el-button type="primary" @click="dqchanpingguige()"
                  >添加</el-button
                >
                <el-button type="warning">删除</el-button>
                <el-button type="danger">清空</el-button>
              </el-form-item>
            </el-form>
            <el-table
              :data="
                cptableData.slice(
                  (currentPage - 1) * pageSize,
                  currentPage * pageSize
                )
              "
              border
              style="width: 100%"
              fit
              size="medium"
              :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
            >
              <el-table-column type="selection" width="55"> </el-table-column>
              <el-table-column fixed prop="product_type_name" label="系列" width="150">
              </el-table-column>
              <el-table-column prop="product_type_pname" label="类型" width="120">
              </el-table-column>
              <el-table-column prop="specification_number" label="规格" width="120">
              </el-table-column>
              <el-table-column prop="price" label="单价" width="120">
              </el-table-column>
              <el-table-column prop="count" label="订货数量" width="120">
              </el-table-column>
              <el-table-column prop="total" label="总价" width="120">
                
              </el-table-column>
            </el-table>
            <div style="margin-top: 20px; font-size: 20px">
              合计数量：{{totalzs}}件  合计总价：{{totaljiage}}元
            </div>
            <div style="margin-top: 20px; font-size: 20px">
              使用积分 <el-input v-model="form.use_points" style="width: 200px;"></el-input>
              <span>可使用积分：{{ksyjifen.can_use_points}}</span>
              <div style="margin-top: 10px;">可使用积分不能超过订单总额的{{ksyjifen.max_use_point_percent}}%</div>
            </div>
            <el-form>
              <el-form-item label="备注">
                <el-input type="" v-model="form.remark"></el-input>
              </el-form-item>
            </el-form>
            <el-button type="primary" @click="dinhuosq()">保存</el-button>
            <el-button type="warning"> 返回</el-button>
          </div>
        </el-dialog>
        <el-dialog
          title="产品规格明细表"
          :visible.sync="chanpingguige"
          width="40%"
          :before-close="handleClose"
        >
          <div style="width: 100%; height: 500px">
            <div style="width: 100%; height: 50px">
              <div style="float: left; width: 50%; float: left">
                <div style="float: left; line-height: 30px">申请编号：</div>
                <el-input style="width: 200px"></el-input>
                <el-button type="primary">刷新</el-button>
              </div>
              <div style="float: left; width: 50%; float: left">
                <div style="float: left; line-height: 30px">申请时间：</div>
                <el-date-picker
                  v-model="value1"
                  type="date"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </div>
            </div>
            <div style="float: left; width: 100%; height: 400px">
              <div style="float: left; width: 50%; height: 100%">
                <el-tree
                  :data="cplistmx"
                  :props="defaultProps"
                  :accordion="false"
                  @node-click="handleNodeClickcp"
                 
                  ref="tree"
                ></el-tree>
              </div>
              <div style="float: left; width: 50%; height: 100%">
                <el-table
                  :data="cpmingxi"
                  border
                  style="width: 100%"
                  fit
                  size="medium"
                  :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
                  height="300"
                  ref="multipleTable"
                  tooltip-effect="dark"
                  @selection-change="handleSelectionChange"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column
                    fixed
                    prop="specification_number"
                    label="产品规格"
                    width="100"
                  >
                  </el-table-column>
                  <el-table-column prop="price" label="产品单价" width="120">
                  </el-table-column>
                  <el-table-column label="产品数量" width="120" prop="count">
                    <template slot-scope="scope">
                      <el-input
                        style="width: 100px"
                        v-model="scope.row.count"
                       
                        size="small"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column prop="total" label="总价" width="120">
                    <template slot-scope="scope">
                    {{scope.row.total = scope.row.count* scope.row.price}}
                  
                    </template>
                  </el-table-column>
                  <el-table-column prop="remark" label="备注" width="120">
                    <template slot-scope="scope">
                      <el-input
                        style="width: 100px"
                        v-model="scope.row.remark"
                        @change="handleScoreChange(scope.row)"
                        size="small"
                      ></el-input>
                    </template>
                  </el-table-column>
                </el-table>
                <el-button type="primary" @click="tianjiacp">添加</el-button>
                <el-button type="primary">返回</el-button>
              </div>
            </div>
          </div>
        </el-dialog>
        <el-dialog
          title="添加地区"
          :visible.sync="dialogVisiblea"
          width="10%"
          :before-close="handleClose"
        >
          <div style="width: 100%">
            <el-button type="primary" @click="hospitalyiyuan(1)">医院</el-button>
            <el-button type="primary" @click="hospitalyiyuan(2)">地区</el-button>
          </div>
        </el-dialog>
        <el-dialog
          title="经销商地址管理"
          :visible.sync="jinxiaoshang"
          width="40%"
          :before-close="handleClose"
        >
          <div style="width: 100%; height: 500px; overflow-y: auto">
            <div
              class="listdizhi"
              @click="dianjidz(item, index)"
              v-for="(item, index) in mrdzlist"
              :key="index"
            >
              <div class="lie">
                <div class="listdizhia">
                  <div>{{ item.name }}</div>
                  <div>{{ item.mobile }}</div>
                  <div style="color: red" v-if="item.type == 1">默认</div>
                </div>
                <div class="listdizhia">
                  <div>{{ item.address }}</div>
                  <div>{{ item.address_info }}</div>
                </div>
              </div>
              <!-- <img
                src="../../assets/401_images/401.gif" v-if="dizhixzindex == index"
                style="width: 40px; height: 40px; margin-top: 30px"
              /> -->
            </div>
            <div style="margin-top: 30px; float: left">
              <el-button type="primary" @click="shouhuor = true"
                >添加</el-button
              >
              <el-button type="warning" @click="shanchudz()">删除</el-button>
            </div>
          </div>
        </el-dialog>
        <el-dialog
          title="收货人地址"
          :visible.sync="shouhuor"
          width="20%"
          :before-close="handleClose"
        >
          <div style="width: 100%; height: 500px">
            <el-form
              ref="dizhilist"
              :model="dizhilist"
              label-width="80px"
              :rules="rules"
            >
              <el-form-item label="收件人" prop="name">
                <el-input v-model="dizhilist.name"></el-input>
              </el-form-item>
              <el-form-item label="手机号码" prop="mobile">
                <!-- <el-select
                  v-model="form.region"
                  style="width: 100px; float: left"
                  placeholder="请选择"
                >
                  <el-option label="+86" value="1"></el-option>
                  <el-option label="+852" value="2"></el-option>
                  <el-option label="+0853" value="3"></el-option>
                  <el-option label="+882" value="4"></el-option>
                </el-select> -->
                <el-input
                  v-model="dizhilist.mobile"
                  style="float: left; width: 200px"
                ></el-input>
              </el-form-item>
              <el-form-item label="所在地区" prop="address">
                <el-input
                  v-model="dizhilist.address"
                  style="width: 200px"
                ></el-input>
                <el-button type="primary" @click="diquxuanzhe = true"
                  >...</el-button
                >
              </el-form-item>
              <el-form-item label="详细地址" prop="address_info">
                <el-input v-model="dizhilist.address_info"></el-input>
              </el-form-item>

              <el-form-item label="标签" prop="type">
                <el-radio-group v-model="dizhilist.type">
                  <el-radio label="1">发票地址</el-radio>
                  <el-radio label="2">合同地址</el-radio>
                  <el-radio label="3">收货地址</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="默认地址">
                <el-checkbox-group v-model="dizhilist.is_default">
                  <el-checkbox label="1" name="type">是否默认</el-checkbox>
                </el-checkbox-group>
              </el-form-item>

              <el-form-item>
                <el-button type="primary" @click="onSubmitxzdz('dizhilist')"
                  >立即创建</el-button
                >
                <el-button>取消</el-button>
              </el-form-item>
            </el-form>
          </div>
        </el-dialog>
        <el-dialog
          title="收货人地址"
          :visible.sync="diquxuanzhe"
          width="30%"
          :before-close="handleClose"
        >
          <div style="width: 100%">
            <!-- <div style="widows: 100%; height:20px;text-align: center ; font-size: 16px; font-weight: 600;" >{{ form.address }}</div> -->
            <!-- <el-tree
            :data="data"
          :props="defaultProps"
           accordion
             @node-click="handleNodeClick">
                             </el-tree> -->
            <div class="shengfen">
              <div class="shshenshienshi">
                <div
                  v-for="(item, index) in datadz"
                  :key="index"
                  class="xx_sf"
                  @click="handleNodeClick(item)"
                >
                  <div
                    :class="{ active: activeIndex == index }"
                    @click="activeIndexsf(index)"
                    class="anniu_xx_xz"
                  >
                    {{ item.area_name }}
                  </div>
                </div>
              </div>
              <div class="shshenshienshi">
                <div
                  v-for="(item, index) in shengxz"
                  :key="index"
                  class="xx_sf"
                  @click="handleNodeClick(item)"
                >
                  <div
                    :class="{ active: activeIndexx == index }"
                    @click="activeIndexq(index)"
                    class="anniu_xx_xz"
                  >
                    {{ item.area_name }}
                  </div>
                </div>
              </div>
              <div class="shshenshienshi">
                <div
                  v-for="(item, index) in shijixz"
                  :key="index"
                  class="xx_sf"
                  @click="handleNodeClick(item)"
                >
                  <div
                    :class="{ active: activeIndexs == index }"
                    @click="activeIndexian(index)"
                    class="anniu_xx_xz"
                  >
                    {{ item.area_name }}
                  </div>
                </div>
              </div>
            </div>
          </div>
        </el-dialog>
        <el-dialog
          title="医院科室查询"
          :visible.sync="hospital"
          width="40%"
          :before-close="handleClose"
        >
          <div style="width: 100%">
            <div class="ipt_a">
              <div style="float: left; line-height: 30px">医院编号：</div>
              <el-input
                v-model="input"
                placeholder="请输入内容"
                style="width: 150px; height: 50px; float: left"
              ></el-input>
            </div>
            <div class="ipt_a">
              <div style="float: left; line-height: 30px">医院名称：</div>
              <el-input
                v-model="input"
                placeholder="请输入内容"
                style="width: 150px; height: 50px; float: left"
              ></el-input>
            </div>
            <div class="ipt_a">
              <el-button type="primary">查询</el-button>
            </div>

            <el-table
              :data="tableDatayyks"
              border
              style="width: 100%"
              fit
              size="medium"
              :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
              ref="singleTable"
              highlight-current-row
              @current-change="handleCurrentChange"
            >
              <el-table-column type="selection" width="55"> </el-table-column>
              <el-table-column
                fixed
                prop="hospital_code"
                label="医院编号"
                width="150"
              >
              </el-table-column>
              <el-table-column prop="hospital_name" label="医院名称">
              </el-table-column>
              <el-table-column prop="enddate" label="科室名称">
              </el-table-column>
              <el-table-column prop="address_province" label="省份">
              </el-table-column>
              <el-table-column prop="address" label="地址"> </el-table-column>
            </el-table>
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[5, 10]"
              :page-size="pageSize"
              :total="tableDatayyks.length"
              layout="total, sizes, prev, pager, next, jumper"
            >
            </el-pagination>
          </div>
        </el-dialog>
        <el-dialog
          title="地区选择"
          :visible.sync="area"
          width="30%"
          :before-close="handleClose"
        >
          <div style="width: 100%">
            <div>
              <el-tree :data="tableDatadq" :props="defaultPropsdq" @node-click="handClickdq"></el-tree>
            </div>
            <div style="margin-top: 30px">
              <el-button type="primary ">放弃返回</el-button>
              <el-button type="primary">确定提交</el-button>
            </div>
          </div>
        </el-dialog>
        <div style="margin-top: 30px">
          <template>
            <el-table
              :data="tableData"
              border
              style="width: 100%"
              fit
              size="medium"
              height="400"
              :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
            >
              <el-table-column type="selection" width="50"> </el-table-column>
              <el-table-column
                fixed
                prop="order_no"
                label="申请编号"
                width="300"
              >
              </el-table-column>
              <el-table-column prop="create_time" label="申请日期" width="300">
              </el-table-column>
              <el-table-column
                prop="order_type_txt"
                label="订单类型"
                width="300"
              >
              </el-table-column>
              <el-table-column prop="use_points" label="使用积分" width="300">
              </el-table-column>
              <el-table-column
                prop="hospital_name"
                label="订货医院或地区"
                width="300"
              >
              </el-table-column>
              <el-table-column prop="address" label="订货状态" width="300">
              </el-table-column>
              <el-table-column prop="company_name" label="订货方" width="300">
              </el-table-column>
              <el-table-column prop="jingxiaos" label="订货方地址" width="300">
                <el-button>联系方式</el-button>
              </el-table-column>
              <el-table-column prop="sh_name" label="收货人" width="300">
              </el-table-column>
              <el-table-column prop="sh_mobile" label="收货人电话" width="300">
              </el-table-column>
              <el-table-column
                prop="sh_address_txt"
                label="收货地址"
                width="300"
              >
              </el-table-column>
              <el-table-column prop="jingxiaos" label="付款凭证" width="150">
              </el-table-column>
              <el-table-column prop="jingxiaos" label="财务发票" width="150">
                <template slot-scope="scope">
                  <!-- <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button> -->
                  <el-button
                    size="mini"
                    @click="handleEdit(scope.$index, scope.row)"
                    >下载</el-button
                  >
                </template>
              </el-table-column>
              <el-table-column prop="peisonf" label="签字回单" width="150">
                <template slot-scope="scope">
                  <!-- <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button> -->
                  <el-button
                    size="mini"
                    @click="handleEdit(scope.$index, scope.row)"
                    >上传</el-button
                  >
                </template>
              </el-table-column>

              <el-table-column label="操作日志" width="150">
                <template>
                  <!-- <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button> -->
                  <el-button
                    size="mini"
                    @click="handleEdit(scope.$index, scope.row)"
                    >审核日志</el-button
                  >
                </template>
              </el-table-column>
              <el-table-column prop="vip" label="备注" width="150">
              </el-table-column>
            </el-table>
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[5, 10]"
              :page-size="pageSize"
              :total="tablelength"
              layout="total, sizes, prev, pager, next, jumper"
            >
            </el-pagination>
          </template>
        </div>
      </div>
    </div>

    <div class="my-body">
      <div>
        <div style="float: left">
          <el-button type="primary" plain>查看物流</el-button>
          <el-button type="danger" plain>订单货</el-button>
        </div>

        <div style="float: left; margin-left: 20px; line-height: 30px">
          申请信息:申请编号【DH037807742409180001】应付货款【47422】
        </div>
        <div style="width: 100%; float: left; margin-top: 20px">
          <template>
            <el-table
              :data="
                tableDatas.slice(
                  (currentPage - 1) * pageSize,
                  currentPage * pageSize
                )
              "
              style="width: 100%"
              border
              fit
              size="medium"
              :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
            >
              <el-table-column type="selection" width="55"> </el-table-column>
              <el-table-column
                fixed
                prop="bianhao"
                label="产品序列"
                width="150"
              >
              </el-table-column>
              <el-table-column prop="senddate" label="产品类型">
              </el-table-column>
              <el-table-column prop="enddate" label="产品规格">
              </el-table-column>
              <el-table-column prop="name" label="单价"> </el-table-column>
              <el-table-column prop="province" label="订货数量">
              </el-table-column>

              <el-table-column prop="vip" label="备注" width="200">
              </el-table-column>
            </el-table>
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[5, 10]"
              :page-size="pageSize"
              :total="tableData.length"
              layout="total, sizes, prev, pager, next, jumper"
            >
            </el-pagination>
          </template>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getData, postData } from "@/utils/request.js";
export default {
  data() {
    return {
      key: 1, // 为了能每次切换权限的时候重新初始化指令
      options: [
        {
          value: "1",
          label: "全部",
        },
        {
          value: "2",
          label: "已签收",
        },
        {
          value: "3",
          label: "未签收",
        },
      ],
      data: [
        {
          label: "中国大陆",
          children: [
            {
              label: "上海",
            },
            {
              label: "北京",
            },
            {
              label: "四川",
            },
          ],
        },
      ],
      tableDatas:[],
      value1: "",
      value: "",
      chanpingguige: false,
      dialogVisible: false,
      dialogVisiblea: false,
      hospital: false,
      area: false,
      currentPage: 1,
      pageSize: 5,
      jinxiaoshang: false,
      shouhuor: false,
      diquxuanzhe: false,
      activeIndex: "-1",
      activeIndexx: "-1",
      activeIndexs: "-1",
      shengxz: [],
      shijixz: [],
      color: "#fff",
      tableData: [
        {
          bianhao: "PS074107742412L",
          senddate: "2024-05-02",
          enddate: "2024-12-31",
          name: "左心耳",
          province: "完成授权",
          city: "普陀区",
          address: "苏州市中心医院",
          shouqfang: "鹰潭市方园医药有限公司",
          jingxiaos: "鹰潭市方园医药有限公司",
          peisonf: "鹰潭市方园医药有限公司",
          shouqyy: "入院",
          shangcaizhibiao: 3,
        },
      ],
      input: "",
      form: {
        name: "",
        type: "",
        hospital_id: "",
        area_id: "",
        fp_address: "",
        ht_address: "",
        sh_address: "",
        fp_addressname: "",
        ht_addressname: "",
        sh_addressname: "",
        total_num: "",
        total_price: "",
        use_points: "0",
        remark: "",
        region: "",
        product: "",
        company_code: "",
        area_code: "",
        approval_type: "",
        com_id: "",
        hospitalname: "",
        hospital_code: "",
        yiyianname:"",
        yiyiancode:"",
      },
      dizhilist: {
        name: "",
        mobile: "",
        address: "",
        address_info: "",
        type: "",
        is_default: "",
      },
      mrdzlist: "",
      sizeForm: {
        name: "",
        type: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        resource: "",
        desc: "",

        dizhilistlx: "",
        address_type: [],
        datadz: [],
        cplistmx: [],
        dizhixzindex: "",
      },
      tableDatayyks: [],
      defaultProps: {
        children: "children",
        label: "name",
      },
      defaultPropsdq: {
        children: "children",
        label: "area_name",
      },
      totaljiage:"",//总价
      totalzs:"",
      cpmingxi: [],
      rules: {
        name: [
          { required: true, message: "请输入名称", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        mobile: [
          { required: true, message: "请输入手机号码", trigger: "blur" },
          { min: 11, message: "长度在11 个字符", trigger: "blur" },
        ],
        address: [
          { required: true, message: "请选择所在地区", trigger: "change" },
        ],
        address_info: [
          { required: true, message: "请输入详细地址", trigger: "change" },
        ],
        type: [{ required: true, message: "请选择地址", trigger: "change" }],
      },
      scid: "",
      cptableData: [],
      ck_name: "",
      abbreviation: "",
      cpxzguige:[],
      tableDatadq:[],
      ksyjifen:"",
    };
  },
 

  created() {
    this.dhlist();
    this.getHospital();
    this.form.com_id = localStorage.getItem("company_id");
    this.form.name = localStorage.getItem("company_name");
    this.getParams();
    this.dzcs();
   
  },
  methods: {
    dinhuoshenq(){
      this.dialogVisible = true
    },
   
    handClickdq(data){
     
      this.form.yiyiancode =data.dms_city_code
     this.form.yiyianname =data.area_name
     this.form.area_code =data.dms_city_code
     this.form.area_id = data.area_id
     this.area = false;
     this.dialogVisiblea = false;
     this.hospital = false;
    },
    dinhuosq(){
      
      var data = {
        company_id:this.form.com_id,
        type:this.form.type,
        hospital_id:this.form.hospital_id,
        area_id:this.form.area_id,
        fp_address:JSON.stringify(this.form.fp_address),
        ht_address:JSON.stringify(this.form.ht_address),
        sh_address:JSON.stringify(this.form.sh_address),
        total_num:this.totalzs,
        total_price:this.totaljiage,
        use_points:this.form.use_points,
        remark:this.form.remark,
        product:JSON.stringify(this.cptableData),
        company_code:localStorage.getItem("company_code"),
        area_code:this.form.area_code,
        hospital_code:this.form.hospital_code,
      
        token: localStorage.getItem("token"),
      };
      postData("order/operation", data).then((res) => {
        console.log(res.data);
       
      });
    },
    dqchanpingguige(){
      if(this.form.yiyianname == '' && this.form.yiyiancode == ''){
        this.$message({
          message: '没有有效授权',
          type: 'warning'
        });
      }else{
        this.chanpingguige= true
      }
     
    },
    handleSelectionChange(val) {
      this.cpxzguige =val
       console.log(val)
      },
    handleNodeExpand(data, node, self) {
      console.log("节点展开", data, node);
      this.abbreviation = data.abbreviation;
      // 在这里可以获取到当前展开的节点数据
      if (this.currentNode && this.currentNode !== node) {
        this.currentNode.expanded = false;
      }
      this.currentNode = node;
      this.$refs.tree.store.nodesMap[node.id].expanded = !node.expanded;
    },
    handleNodeCollapse(data) {
      console.log("节点折叠", data);

      // 在这里可以获取到当前折叠的节点数据
    },
    tianjiacp() {
      if(this.cpxzguige == ''){
        this.$message({
            message: "警告哦，您还没有勾选产品哦",
            type: "warning",
          });
      }else{
        this.cptableData = this.cpxzguige;
      console.log(this.cptableData);
    
      this.totaljiage = this.cptableData.map((row) => row.count * row.price).reduce((total, num) => total + num);
     this.totalzs = this.cptableData.map((row) => row.count*1).reduce((total, num) => total + num);
    
      this.chanpingguige = false
      this.getinfojf()
      }
      
    },
    //获取可使用积分情况
    getinfojf(){
      
      var data = {
        company_id:localStorage.getItem("company_id"),
        hospital_id:this.form.hospital_id,
        area_id:this.form.area_id,
        product:JSON.stringify(this.cptableData),
        token: localStorage.getItem("token"),
      };
      postData("order/getPointsInfo", data).then((res) => {
        console.log(res.data);
       this.ksyjifen = res.data
      });
    },
    handleScoreChange(row) {
      // 这里可以处理输入后的数据，例如发送到服务器
      console.log("更新后的成绩:", row);
    },
    dzcs() {
      var data = {
        token: localStorage.getItem("token"),
      };
      postData("hospital/getParams", data).then((res) => {
        console.log(res.data);
        this.datadz = res.data.area;
        // this.shengxz = res.data.area[0].children;
        // this.shijixz =res.data.area[0].children[0].children;
      });
    },
    //产品类型

    cpindexlist() {
      var data = {
        company_id:localStorage.getItem("company_id"),
        hospital_area_id:this.form.hospital_id,
        sq_type:this.form.type,
        token: localStorage.getItem("token"),
      };
      postData("product.Specifications/getbuyProduct", data).then((res) => {
        this.cplistmx = res.data;
        console.log(this.cplistmx);
      });
    },
    shanchudz() {
      var data = {
        token: localStorage.getItem("token"),
        ids: this.scid,
      };
      postData("company.address/del", data).then((res) => {
        console.log(res.data);
      });
    },
    onSubmitxzdz(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var data = {
            name: this.dizhilist.name,
            mobile: this.dizhilist.mobile,
            address: this.dizhilist.address,
            address_info: this.dizhilist.address_info,
            type: this.dizhilist.type,
            is_default: this.dizhilist.is_default,
            token: localStorage.getItem("token"),
          };
          postData("company.address/operation", data).then((res) => {
            // 处理响应数据
            if (res.code == 0) {
              console.log(res);
              this.dizhilistlx = res.data.company_address_type;
            } else {
            }
          });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    //公司地址列表

    getParams() {
      var data = {
        token: localStorage.getItem("token"),
      };
      postData("company.address/getParams", data).then((res) => {
        // 处理响应数据
        if (res.code == 0) {
          console.log(res);
          this.dizhilistlx = res.data.company_address_type;
        } else {
        }
      });
    },
    //地址选择状态
    dianjidz(item, index) {
      if (this.address_type == 1) {
        this.dizhixzindex = index;
        this.scid = item.id;
        this.form.fp_address = item;
        this.form.fp_addressname = item.address + item.address_info;
      } else if (this.address_type == 2) {
        this.dizhixzindex = index;
        this.scid = item.id;
        this.form.ht_address = item;
        this.form.ht_addressname = item.address + item.address_info;
      } else if (this.address_type == 3) {
        this.dizhixzindex = index;
        this.scid = item.id;
        this.form.sh_address = item;
        this.form.sh_addressname = item.address + item.address_info;
      }
      console.log(item);

      this.jinxiaoshang = false;
    },
    indexlist(e) {
      var data = {
        company_id: localStorage.getItem("company_id"),
        address_type: e,
        token: localStorage.getItem("token"),
      };
      postData("company.Address/indexlist", data).then((res) => {
        // 处理响应数据
        if (res.code == 0) {
          console.log(res);
          this.mrdzlist = res.data.data;
        } else {
        }
      });
    },
    //地址选择
    jinxiaoshangdz(e) {
      this.jinxiaoshang = true;
     
      this.address_type = e;
      this.indexlist(e);
    },
    //地区选择省市区
    activeIndexsf(e) {
      this.activeIndex = e;
      this.activeIndexx = "-1";
      this.activeIndexs = "-1";
    },
    activeIndexq(e) {
      this.activeIndexx = e;
    },
    activeIndexian(e) {
      this.activeIndexs = e;
    },
    handleNodeClickcp(data, node, self) {
      if (data.ck_name == null || data.ck_name == "") {
        this.abbreviation = data.abbreviation;
      } else {
        this.ck_name = data.ck_name;
      }
      console.log(this.abbreviation, this.ck_name);

      console.log(data);
      var data = {
        company_id: localStorage.getItem("company_id"),
        hospital_id: this.form.hospital_id,
        product_type_id: data.id,
        area_id:this.form.area_id,
        token: localStorage.getItem("token"),
      };
      postData("product.Specifications/getbuyProductSpecifications", data).then(
        (res) => {
          // 处理响应数据
          if (res.code == 0) {
            console.log(res);
            this.cpmingxi = res.data;
          } else {
          }
        }
      );
    },
    handleNodeClick(data) {
      this.color = this.color === "#fff" ? "blue" : "#fff";
      console.log(data.area_deep);
      console.log(data);

      if (data.area_deep == 1) {
        this.form.address = "";
        this.shengxz = data.children;

        this.shenshi = data.area_name;
        this.form.address = this.shenshi;

        console.log(this.shenshi);
      } else if (data.area_deep == 2) {
        if (this.shenshi == "") {
          this.$message({
            message: "警告哦，您还没有选择省",
            type: "warning",
          });
        } else {
          this.form.address = "";
          this.shijixz = data.children;
          this.shiji = this.shenshi + "-" + data.area_name;
          this.form.address = this.shiji;
        }
      } else if (data.area_deep == 3) {
        if (this.shiji == "") {
          this.$message({
            message: "警告哦，您还没有选择市",
            type: "warning",
          });
        } else {
          this.form.address = "";
          this.quxian = this.shiji + "-" + data.area_name;
          this.dizhilist.address = this.quxian;
          this.diquxuanzhe = false;
        }
      }

      this.dizhics = data;
      this.form.area_id = data.area_id;
    },
    hospitalyiyuan(e) {
      this.form.type = e;
      if(e == 1){
      this.hospital = true;
      this.form.area_id = ''
      this.setCurrent()
     
      }else{
        this.area = true
        this.form.hospital_id = ''
        this.qiyelistdq()
      }
      console.log(this.form.type)
     
    },
    //获取医院列表

    getHospital() {
      var data = {
        company_id: localStorage.getItem("company_id"),
        token: localStorage.getItem("token"),
      };
      postData("company.contract/getHospital", data).then((res) => {
        // 处理响应数据
        if (res.code == 0) {
          console.log(res);
          this.tableDatayyks = res.data.data;
        } else {
        }
      });
    },

    //医院列表单选
    handleCurrentChange(val) {
      console.log(val, 66666666666666666666666);
     
      this.currentRow = val;
      this.form.hospitalname = val.hospital_name;
      this.form.hospital_code = val.hospital_code;
      this.form.yiyianname = val.hospital_name;
      this.form.yiyiancode = val.hospital_code;
      this.form.hospital_id = val.id;
      this.dialogVisiblea = false;
      this.hospital = false;
      this.cpindexlist();
    },
    setCurrent(row) {
        this.$refs.singleTable.setCurrentRow(row);
      },
    //订单申请列表
    dhlist() {
      var data = {
        page: 1,
        limit: 100,
        token: localStorage.getItem("token"),
      };
      postData("order/dhList", data).then((res) => {
        // 处理响应数据
        if (res.code == 0) {
          console.log(res);
          this.tableData = res.data.data;
          this.tablelength = res.data.total;
        } else {
        }
      });
    },
    //获取企业签合同的地区列表
    qiyelistdq() {
      var data = {
        company_id: localStorage.getItem("company_id"),
        token: localStorage.getItem("token"),
      };
      postData("company.contract/getArea", data).then((res) => {
        // 处理响应数据
        if (res.code == 0) {
          console.log(res);
          this.tableDatadq = res.data.data
        } else {
        }
      });
    },
    onSubmit() {
      console.log("submit!");
    },
    handleClose(done) {
      done();
      // this.$confirm('确认关闭？')
      // 	.then(_ => {
      // 		done();
      // 	})
      // 	.catch(_ => {});
    },

    handleClick(row) {
      console.log(row);
    },
    handleSizeChange(val) {
      this.pageSize = val;
    },
  },
};
</script>

<style lang="scss" scoped>
.ipt_a {
  width: 300px;
  height: 50px;
  float: left;
}

.ipt_b {
  width: 450px;
  height: 50px;
  float: left;
}

.listdizhi {
  width: 100%;
  height: 100px;
  float: left;
  border-bottom: 1px solid;
}

.lie {
  width: 90%;
  height: 100%;
  float: left;
}

.listdizhia {
  width: 100%;
  height: 50px;
  float: left;
}

.listdizhia div {
  float: left;
  margin-left: 30px;
}

.xx_sf {
  width: 100%;
  height: 24px;
  float: left;
}
.anniu_xx_xz {
  width: 100%;
  height: 24px;
  float: left;
  text-align: center;
  line-height: 24px;
}

.active {
  width: 100%;
  height: 24px;
  float: left;
  background-color: #1890ff;
  border-radius: 5px;
  text-align: center;
  color: #fff;
}
.shengfen {
  width: 100%;
  height: 400px;
  overflow-y: scroll;
}

.shshenshienshi {
  width: 33%;
  float: left;
}
</style>